<?php

use Biz\Constants\Site\SiteMailConstants;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * SiteMail.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class SiteMail extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        /**
         * @see config('mail')
         */
        Schema::create('site_mail', function (Blueprint $table) {
            $table->bigIncrements('id');//BigID unsigned
            $table->bigInteger('site_id')->unsigned();//所属站点ID
            $table->string('driver', 16)->default(SiteMailConstants::DRIVER_SMTP);// Mail Driver
            $table->string('host');// SMTP Host Address
            $table->integer('port')->default(587);// SMTP Host Port
            $table->text('from');// Global "From" Address
            $table->string('encryption', 16);// E-Mail Encryption Protocol
            $table->string('username');// SMTP Server Username
            $table->string('password');// SMTP Server Password
            $table->string('sendmail')->default(SiteMailConstants::DEFAULT_SENDMAIL);// 驱动
            $table->tinyInteger('status')->default(SiteMailConstants::STATUS_NORMAL);//状态
            
            // 注意时间戳位数
            $table->timestamps();
            $table->softDeletes();

            // unique index
            $table->unique('site_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('site_mail');
    }
}